<?php
/* SVN FILE: $Id: cp_skin_manage.php 257 2010-01-19 21:50:13Z supersmashbrothers $ */
/**
* ibMarket 2
* IP.Board 3.0
* ibMarket ACP management html
*
* @author $Author: supersmashbrothers $
* @copyright $Copyright$
* @version $Revision: 257 $
* @lastrevision $Date: 2010-01-19 21:50:13 +0000 (Tue, 19 Jan 2010) $
* @modifiedby $LastChangedBy: supersmashbrothers $
* @lastmodified $LastChangedDate: 2010-01-19 21:50:13 +0000 (Tue, 19 Jan 2010) $
* @filesource $URL: http://ipb-ibmarket.googlecode.com/svn/ibmarket2/trunk/admin/applications_addon/other/ibmarket/skin_cp/cp_skin_manage.php $
*/

class cp_skin_manage extends output
{

/**
 * Prevent our main destructor being called by this class
 *
 * @access	public
 * @return	void
 */
public function __destruct()
{
}

/**
 * Manage Forums
 *
 * @access	public
 * @return	string	HTML
 */
public function manageForum( array $forumList ) {
$last = null;

$IPBHTML .= <<<EOF
<script type='text/javascript' src='{$this->settings['js_app_url']}manageForum.js'></script>
<div class='section_title'>
	<h2>{$this->lang->words['manage_forums_title']}</h2>
</div>

<div id='marketForums'>
	<form method='post' action='{$this->settings['base_url']}module=manage&amp;section=forums&amp;do=save' id='itemForm'>
		<input type='hidden' name='_admin_auth_key' value='{$this->registry->adminFunctions->getSecurityKey()}' />

EOF;
foreach($forumList as $forum)
{
	if($last != null && $forum[1] == 0)
	{
		if($last[1] == 0)
		{
			$IPBHTML .= <<<EOF
			<li>
				{$this->lang->words['no_forums']}
			</li>

EOF;
		}
		$IPBHTML .= <<<EOF
			</ul>
		</div>
		<br />

EOF;
	}
	if($forum[1] == 0)
	{
	$IPBHTML .= <<<EOF
		<div class='acp-box'>
			<h3>{$forum[0]['name']}</h3>
			<ul class='acp-form alternate_rows'>

EOF;
	}
	else
	{
		$form['market_reply'] = ipsRegistry::getClass('output')->formYesNo('forum['.$forum[0]['id'].'][market_reply]', $forum[0]['market_reply']);
		$form['market_topic'] = ipsRegistry::getClass('output')->formYesNo('forum['.$forum[0]['id'].'][market_topic]', $forum[0]['market_topic']);
		$form['market_reply_amount'] = marketFormatter::currencyFormat(ipsRegistry::getClass('output')->formSimpleInput('forum['.$forum[0]['id'].'][market_reply_amount]', $forum[0]['market_reply_amount'], 10));
		$form['market_topic_amount'] = marketFormatter::currencyFormat(ipsRegistry::getClass('output')->formSimpleInput('forum['.$forum[0]['id'].'][market_topic_amount]', $forum[0]['market_topic_amount'], 10));
		$depth = str_repeat("--",$forum[1] - 1);
		$IPBHTML .= <<<EOF
			<li>
				{$depth} <strong id='forum-{$forum[0]['id']}' style='text-decoration: underline; cursor: pointer;'>{$forum[0]['name']}</strong>
				<div class='acp-box' id='forum-{$forum[0]['id']}-settings'>
					<h3>{$this->lang->words['forum_settings']}</h3>
					<ul class='acp-form alternate_rows'>
						<li>
							<label>{$this->lang->words['forum_reply_overwrite']}</label>
							{$form['market_reply']}
						</li>
						<li>
							<label>{$this->lang->words['forum_reply_amount']}</label>
							{$form['market_reply_amount']}
						</li>
						<li>
							<label>{$this->lang->words['forum_topic_overwrite']}</label>
							{$form['market_topic']}
						</li>
						<li>
							<label>{$this->lang->words['forum_topic_amount']}</label>
							{$form['market_topic_amount']}
						</li>
					</ul>
				</div>
				<script type='text/javascript'>
					manageForum.register('forum-{$forum[0]['id']}');
				</script>
			</li>

EOF;
	}
	$last = $forum;
}

if($last[1] == 0)
{
	$IPBHTML .= <<<EOF
			<li>
				{$this->lang->words['no_forums']}
			</li>

EOF;
}
$IPBHTML .= <<<EOF
			</ul>
		</div>
		<div class='acp-actionbar'>
			<div class='centeraction'>
				<input type='submit' value='{$this->lang->words['manage_forums_button']}' class='button primary'>
			</div>
		</div>
	</form>
</div>

EOF;

return $IPBHTML;
}

/**
 * Manage wages
 *
 * @access	public
 * @return	string	HTML
 */
public function manageWages( array $members ) {

$IPBHTML .= <<<EOF
<div class='section_title'>
	<h2>{$this->lang->words['manage_wages_title']}</h2>
	<ul class='context_menu'>
		<li>
			<a href='{$this->settings['base_url']}module=manage&amp;section=wages&amp;do=add'>
				<img src='{$this->settings['skin_acp_url']}/_newimages/icons/add.png' alt='' />
				{$this->lang->words['add_wage']}
			</a>
		</li>
	</ul>
</div>

<div id='manageWages'>
	<div class='acp-box'>
		<h3>{$this->lang->words['group_wages']}</h3>
		<table width='100%' cellpadding='0' cellspacing='0' border='0' class='alternate_rows'>
			<tr>
				<th style='white-space:nowrap'>{$this->lang->words['group']}</th>
				<th style='width: 1%; min-width: 200px;white-space:nowrap'>{$this->lang->words['how_much']}</th>
				<th style='width: 1%; min-width: 200px;white-space:nowrap'>{$this->lang->words['next_payment']}</th>
				<th style='width:1px;min-width:1%;white-space:nowrap'>{$this->lang->words['options']}</th>
			</tr>

EOF;
foreach($this->caches['market_wages']['group'] as $wage)
{
	$wage['how_much'] = marketFormatter::formatCurrency($wage['how_much']);
	$wage['next_payment'] = $this->registry->getClass('class_localization')->formatTime($wage['next_payment'],'long');
	$IPBHTML .= <<<EOF
			<tr>
				<td style='white-space:nowrap'>{$this->caches['group_cache'][$wage['id_who']]['prefix']}{$this->caches['group_cache'][$wage['id_who']]['g_title']}{$this->caches['group_cache'][$wage['id_who']]['suffix']}</td>
				<td style='white-space:nowrap'>{$wage['how_much']}</td>
				<td style='white-space:nowrap'>{$wage['next_payment']}</td>
				<td style='width:1px;min-width:1%;white-space:nowrap'>
					<img class='ipbmenu' id="menum-{$wage['w_id']}" src='{$this->settings['skin_acp_url']}/_newimages/menu_open.png' alt='{$this->lang->words['frm_options']}' /> &nbsp;
					<ul class='acp-menu' id='menum-{$wage['w_id']}_menucontent'>
						<li class='icon edit'><a href='{$this->settings['base_url']}module=manage&amp;section=wages&amp;do=edit&amp;wage={$wage['w_id']}'>{$this->lang->words['edit_wage']}</a></li>
						<li class='icon delete'><a href='{$this->settings['base_url']}module=manage&amp;section=wages&amp;do=delete&amp;wage={$wage['w_id']}'>{$this->lang->words['delete_wage']}</a></li>
					</ul>
				</td>
			</tr>

EOF;
}
if(count($this->caches['market_wages']['group']) == 0)
{
	$IPBHTML .= <<<EOF
			<tr><td colspan='4' style='text-align:center'>{$this->lang->words['no_group_wages']}</td></tr>

EOF;
}
$IPBHTML .= <<<EOF
		</table>
	</div>
	<br />
	<div class='acp-box'>
		<h3>{$this->lang->words['member_wages']}</h3>
		<table width='100%' cellpadding='0' cellspacing='0' border='0' class='alternate_rows'>
			<tr>
				<th style='white-space:nowrap'>{$this->lang->words['member']}</th>
				<th style='width: 1%; min-width: 200px;white-space:nowrap'>{$this->lang->words['how_much']}</th>
				<th style='width: 1%; min-width: 200px;white-space:nowrap'>{$this->lang->words['next_payment']}</th>
				<th style='width:1px;min-width:1%;white-space:nowrap'>{$this->lang->words['options']}</th>
			</tr>

EOF;
foreach($this->caches['market_wages']['member'] as $wage)
{
	$wage['how_much'] = marketFormatter::formatCurrency($wage['how_much']);
	$wage['next_payment'] = $this->registry->getClass('class_localization')->formatTime($wage['next_payment'],'long');
	$IPBHTML .= <<<EOF
			<tr>
				<td style='white-space:nowrap'>{$members[$wage['id_who']]}</td>
				<td style='white-space:nowrap'>{$wage['how_much']}</td>
				<td style='white-space:nowrap'>{$wage['next_payment']}</td>
				<td style='width:1px;min-width:1%;white-space:nowrap'>
					<img class='ipbmenu' id="menum-{$wage['w_id']}" src='{$this->settings['skin_acp_url']}/_newimages/menu_open.png' alt='{$this->lang->words['frm_options']}' /> &nbsp;
					<ul class='acp-menu' id='menum-{$wage['w_id']}_menucontent'>
						<li class='icon edit'><a href='{$this->settings['base_url']}module=manage&amp;section=wages&amp;do=edit&amp;wage={$wage['w_id']}'>{$this->lang->words['edit_wage']}</a></li>
						<li class='icon delete'><a href='{$this->settings['base_url']}module=manage&amp;section=wages&amp;do=delete&amp;wage={$wage['w_id']}'>{$this->lang->words['delete_wage']}</a></li>
					</ul>
				</td>
			</tr>

EOF;
}
if(count($this->caches['market_wages']['member']) == 0)
{
	$IPBHTML .= <<<EOF
			<tr><td colspan='4' style='text-align:center'>{$this->lang->words['no_member_wages']}</td></tr>

EOF;
}
$IPBHTML .= <<<EOF
		</table>
	</div>
</div>

EOF;

return $IPBHTML;
}

/**
 * Adding/editing wage form
 *
 * @access	public
 * @return	string	HTML
 */
public function wageForm( array $wage, $nextDo, $title, $submitValue ) {

$oftenOption   = array();
$oftenOption[] = array(1, $this->lang->words['restock_option_1']);
$oftenOption[] = array(2, $this->lang->words['restock_option_2']);

$minute = array();
for($i = 0; $i < 60; $i++)
{
	$minute[$i] = array($i,sprintf($this->lang->words['x_minutes'],$i)." (:".sprintf("%02u",$i).")");
}
$minute[1] = array(1, $this->lang->words['1_minute']." (:01)");

$hours = array();
for($i = 0; $i < 24; $i++)
{
	if($i < 12)
	{
		$hours[$i] = array($i, sprintf($this->lang->words['x_hours'],$i)." (".$i." AM)");
	}
	else
	{
		$hours[$i] = array($i, sprintf($this->lang->words['x_hours'],$i)." (".($i - 12)." PM)");
	}
}
$hours[0]  = array(0,  sprintf($this->lang->words['x_hours'],0)." (12 AM)");
$hours[1]  = array(1,  $this->lang->words['1_hour']." (1 AM)");
$hours[24] = array(24, sprintf($this->lang->words['x_hours'],24)." (".$this->lang->words['every_anyhour'].")");

$days = array();
$days[0] = array(0, sprintf($this->lang->words['x_days'],0)." (".$this->lang->words['dayweek0'].")");
$days[1] = array(1, $this->lang->words['1_day']." (".$this->lang->words['dayweek1'].")");
$days[2] = array(2, sprintf($this->lang->words['x_days'],2)." (".$this->lang->words['dayweek2'].")");
$days[3] = array(3, sprintf($this->lang->words['x_days'],3)." (".$this->lang->words['dayweek3'].")");
$days[4] = array(4, sprintf($this->lang->words['x_days'],4)." (".$this->lang->words['dayweek4'].")");
$days[5] = array(5, sprintf($this->lang->words['x_days'],5)." (".$this->lang->words['dayweek5'].")");
$days[6] = array(6, sprintf($this->lang->words['x_days'],6)." (".$this->lang->words['dayweek6'].")");
$days[7] = array(7, sprintf($this->lang->words['x_days'],7)." (".$this->lang->words['every_anyday'].")");

if($wage['to_who'] == 'm')
{
	$member = $this->DB->buildAndFetch(array('select'=>'*','from'=>'members','where'=>"member_id=".$wage['id_who']));
}

$date = IPSTime::unixstamp_to_human($wage['w_when']);
$wage['w_when'] = sprintf("%02d/%02d/%04d %02d:%02d", $date['month'], $date['day'], $date['year'], $date['hour'] , $date['minute'] );

$form['member'] = ipsRegistry::getClass('output')->formInput('member_name', $member['members_display_name']);
$form['group'] = ipsRegistry::getClass('output')->generateGroupDropdown('group_id', $wage['to_who'] == 'g' ? $wage['id_who'] : 0);
$form['how_much'] = marketFormatter::currencyFormat(ipsRegistry::getClass('output')->formSimpleInput('how_much', $wage['how_much'], 10));
$form['option'] = ipsRegistry::getClass('output')->formDropdown('w_how', $oftenOption, $wage['w_how']);
$form['when'] = ipsRegistry::getClass('output')->formInput('w_when', $wage['w_when']);
$form['minute'] = ipsRegistry::getClass('output')->formDropdown('w_minute', $minute, $wage['w_minute']);
$form['hour'] = ipsRegistry::getClass('output')->formDropdown('w_hour', $hours, $wage['w_hour']);
$form['day'] = ipsRegistry::getClass('output')->formDropdown('w_day', $days, $wage['w_day']);

$IPBHTML .= <<<EOF
<script type='text/javascript' language='javascript'>
	ipb.lang['1_minute'] = "{$this->lang->words['1_minute']}";
	ipb.lang['x_minutes'] = "{$this->lang->words['x_minutes']}";
	ipb.lang['1_hour'] = "{$this->lang->words['1_hour']}";
	ipb.lang['x_hours'] = "{$this->lang->words['x_hours']}";
	ipb.lang['1_day'] = "{$this->lang->words['1_day']}";
	ipb.lang['x_days'] = "{$this->lang->words['x_days']}";
	ipb.lang['dayweek0'] = "{$this->lang->words['dayweek0']}";
	ipb.lang['dayweek1'] = "{$this->lang->words['dayweek1']}";
	ipb.lang['dayweek2'] = "{$this->lang->words['dayweek2']}";
	ipb.lang['dayweek3'] = "{$this->lang->words['dayweek3']}";
	ipb.lang['dayweek4'] = "{$this->lang->words['dayweek4']}";
	ipb.lang['dayweek5'] = "{$this->lang->words['dayweek5']}";
	ipb.lang['dayweek6'] = "{$this->lang->words['dayweek6']}";
	ipb.lang['wage_bad_input'] = "{$this->lang->words['wage_bad_input']}";
	ipb.lang['bad_time_format'] = "{$this->lang->words['bad_time_format']}";
	ipb.lang['wage_time_1'] = "{$this->lang->words['wage_time_1']}";
	ipb.lang['wage_time_2'] = "{$this->lang->words['wage_time_2']}";
	ipb.lang['wage_message_1'] = "{$this->lang->words['wage_message_1']}";
	ipb.lang['wage_message_1_every_second'] = "{$this->lang->words['wage_message_1_every_second']}";
	ipb.lang['wage_message_2'] = "{$this->lang->words['wage_message_2']}";
	ipb.lang['every_day_every_hour_x_minute'] = "{$this->lang->words['every_day_every_hour_x_minute']}";
	ipb.lang['every_day_at_time'] = "{$this->lang->words['every_day_at_time']}";
	ipb.lang['every_x_at_time'] = "{$this->lang->words['every_x_at_time']}";
</script>
<script type='text/javascript' src='{$this->settings['js_app_url']}wageForm.js'></script>
<div class='section_title'>
	<h2>{$title}</h2>
</div>

<div id='wageFormPage'>
	<form method='post' action='{$this->settings['base_url']}module=manage&amp;section=wages&amp;do={$nextDo}' id='wageForm'>
		<input type='hidden' name='_admin_auth_key' value='{$this->registry->adminFunctions->getSecurityKey()}' />
		<input type='hidden' name='wage' value='{$wage['w_id']}' />
		<div class='acp-box'>
			<h3>{$title}</h3>
			<ul class='acp-form alternate_rows'>
EOF;
if(!$wage['to_who'] || $wage['to_who'] == 'm')
{
	$IPBHTML .= <<<EOF
				<li>
					<label>{$this->lang->words['wage_which_member']}</label>
					{$form['member']}
				</li>
EOF;
}
if(!$wage['to_who'])
{
	$IPBHTML .= <<<EOF
				<li>
					<label style='text-align:center;width:100%'>{$this->lang->words['__or__']}</label>
				</li>
EOF;
}
if(!$wage['to_who'] || $wage['to_who'] == 'g')
{
	$IPBHTML .= <<<EOF
				<li>
					<label>{$this->lang->words['wage_which_group']}</label>
					{$form['group']}
				</li>
EOF;
}
$IPBHTML .= <<<EOF
				<li>
					<label>{$this->lang->words['wage_how_much']}</label>
					{$form['how_much']}
				</li>
				<li><label class='head'><input id="paymentInfo" class="textinput" type="text" size="1" style="float:right; width:60%; min-width: 500px; margin-right: 5px" />{$this->lang->words['wage_how_often']}</label></li>
				<li>
					<label>{$this->lang->words['wage_when_to_give']}</label>
					{$form['option']}
				</li>
				<li id='li_wage_when'>
					<label>
						{$this->lang->words['wage_last_paid']}
						<span class="desctext" style='white-space: nowrap'>{$this->lang->words['wage_last_paid_desc']}</span>
					</label>
					{$form['when']}<input id="currentTimeButton" type="button" value="{$this->lang->words['wage_current_time']}" />
				</li>
				<li>
					<label>
						<span id='wage_time_ques'></span>
					</label>
					<div style='display: inline-block'>
						{$form['day']}
						<br />
						{$form['hour']}
						<br />
						{$form['minute']}
					</div>
				</li>
			</ul>
			<div class='acp-actionbar'>
				<div class='centeraction'>
					<input type='submit' value='{$submitValue}' class='button primary'>
				</div>
			</div>
		</div>
	</form>
</div>
EOF;

return $IPBHTML;
}

/**
 * Manage taxes
 *
 * @access	public
 * @return	string	HTML
 */
public function manageTaxes() {

$IPBHTML .= <<<EOF
<div class='section_title'>
	<h2>{$this->lang->words['manage_taxes_title']}</h2>
	<ul class='context_menu'>
		<li>
			<a href='{$this->settings['base_url']}module=manage&amp;section=taxes&amp;do=add'>
				<img src='{$this->settings['skin_acp_url']}/_newimages/icons/add.png' alt='' />
				{$this->lang->words['add_tax']}
			</a>
		</li>
	</ul>
</div>

<div id='manageTaxes'>
	<div class='acp-box'>
		<h3>{$this->lang->words['money_on_hand']}</h3>
		<table width='100%' cellpadding='0' cellspacing='0' border='0' class='alternate_rows'>
			<tr>
				<th style='width: 1%; min-width: 200px;white-space:nowrap'>{$this->lang->words['money_range']}</th>
				<th style='width: 1%; min-width: 200px;white-space:nowrap'>{$this->lang->words['time_interval']}</th>
				<th style='white-space:nowrap'>{$this->lang->words['taxed']}</th>
				<th style='width:1px;min-width:1%;white-space:nowrap'>{$this->lang->words['options']}</th>
			</tr>

EOF;
foreach($this->caches['market_taxes']['hand'] as $tax)
{
	$range = str_replace("<#MIN#>",marketFormatter::formatCurrency($tax['range_min']),$this->lang->words['min_to_max']);
	$range = str_replace("<#MAX#>",numbers::compare($tax['range_max']) <= 0 ? $this->lang->words['infinite'] : marketFormatter::formatCurrency($tax['range_max']),$range);
	$interval = marketFormatter::relativeTimeFull($tax['interval']);
	$taxed = str_replace("<#FIXED#>",marketFormatter::formatCurrency($tax['tax_fix']),$this->lang->words['tax_amount']);
	$taxed = str_replace("<#PERCENT#>",marketFormatter::numberFormat($tax['tax_percent'],10),$taxed);
	$taxed = str_replace("<#OVER#>",marketFormatter::formatCurrency($tax['tax_psub']),$taxed);
	$IPBHTML .= <<<EOF
			<tr>
				<td style='white-space:nowrap'>{$range}</td>
				<td style='white-space:nowrap'>{$interval}</td>
				<td style='white-space:nowrap'>{$taxed}</td>
				<td style='width:1px;min-width:1%;white-space:nowrap'>
					<img class='ipbmenu' id="menum-{$tax['t_id']}" src='{$this->settings['skin_acp_url']}/_newimages/menu_open.png' alt='{$this->lang->words['frm_options']}' /> &nbsp;
					<ul class='acp-menu' id='menum-{$tax['t_id']}_menucontent'>
						<li class='icon edit'><a href='{$this->settings['base_url']}module=manage&amp;section=taxes&amp;do=edit&amp;tax={$tax['t_id']}'>{$this->lang->words['edit_tax']}</a></li>
						<li class='icon delete'><a href='{$this->settings['base_url']}module=manage&amp;section=taxes&amp;do=delete&amp;tax={$tax['t_id']}'>{$this->lang->words['delete_tax']}</a></li>
					</ul>
				</td>
			</tr>

EOF;
}
if(count($this->caches['market_taxes']['hand']) == 0)
{
	$IPBHTML .= <<<EOF
			<tr><td colspan='4' style='text-align:center'>{$this->lang->words['no_hand_taxes']}</td></tr>

EOF;
}
$IPBHTML .= <<<EOF
		</table>
	</div>
	<br />
	<div class='acp-box'>
		<h3>{$this->lang->words['post_gained_money']}</h3>
		<table width='100%' cellpadding='0' cellspacing='0' border='0' class='alternate_rows'>
			<tr>
				<th style='width: 1%; min-width: 200px;white-space:nowrap'>{$this->lang->words['money_range']}</th>
				<th style='width: 1%; min-width: 200px;white-space:nowrap'>{$this->lang->words['time_interval']}</th>
				<th style='white-space:nowrap'>{$this->lang->words['taxed']}</th>
				<th style='width:1px;min-width:1%;white-space:nowrap'>{$this->lang->words['options']}</th>
			</tr>

EOF;
foreach($this->caches['market_taxes']['post'] as $tax)
{
	$range = str_replace("<#MIN#>",marketFormatter::formatCurrency($tax['range_min']),$this->lang->words['min_to_max']);
	$range = str_replace("<#MAX#>",numbers::compare($tax['range_max']) <= 0 ? $this->lang->words['infinite'] : marketFormatter::formatCurrency($tax['range_max']),$range);
	$interval = marketFormatter::relativeTimeFull($tax['interval']);
	$taxed = str_replace("<#FIXED#>",marketFormatter::formatCurrency($tax['tax_fix']),$this->lang->words['tax_amount']);
	$taxed = str_replace("<#PERCENT#>",marketFormatter::numberFormat($tax['tax_percent'],10),$taxed);
	$taxed = str_replace("<#OVER#>",marketFormatter::formatCurrency($tax['tax_psub']),$taxed);
	$IPBHTML .= <<<EOF
			<tr>
				<td style='white-space:nowrap'>{$range}</td>
				<td style='white-space:nowrap'>{$interval}</td>
				<td style='white-space:nowrap'>{$taxed}</td>
				<td style='width:1px;min-width:1%;white-space:nowrap'>
					<img class='ipbmenu' id="menum-{$tax['t_id']}" src='{$this->settings['skin_acp_url']}/_newimages/menu_open.png' alt='{$this->lang->words['frm_options']}' /> &nbsp;
					<ul class='acp-menu' id='menum-{$tax['t_id']}_menucontent'>
						<li class='icon edit'><a href='{$this->settings['base_url']}module=manage&amp;section=taxes&amp;do=edit&amp;tax={$tax['t_id']}'>{$this->lang->words['edit_tax']}</a></li>
						<li class='icon delete'><a href='{$this->settings['base_url']}module=manage&amp;section=taxes&amp;do=delete&amp;tax={$tax['t_id']}'>{$this->lang->words['delete_tax']}</a></li>
					</ul>
				</td>
			</tr>

EOF;
}
if(count($this->caches['market_taxes']['post']) == 0)
{
	$IPBHTML .= <<<EOF
			<tr><td colspan='4' style='text-align:center'>{$this->lang->words['no_post_taxes']}</td></tr>

EOF;
}
$IPBHTML .= <<<EOF
		</table>
	</div>
</div>

EOF;

return $IPBHTML;
}

/**
 * Adding/editing tax form
 *
 * @access	public
 * @return	string	HTML
 */
public function taxForm( array $tax, $nextDo, $title, $submitValue ) {

$applyTo = array();
$applyTo[] = array('post',$this->lang->words['post_gained_money']);
$applyTo[] = array('hand',$this->lang->words['money_on_hand']);

$minute = array();
for($i = 0; $i < 60; $i++)
{
	$minute[$i] = array($i,sprintf($this->lang->words['x_minutes'],$i));
}
$minute[1] = array(1, $this->lang->words['1_minute']);

$hours = array();
for($i = 0; $i < 24; $i++)
{
	$hours[$i] = array($i, sprintf($this->lang->words['x_hours'],$i));
}
$hours[1]  = array(1,  $this->lang->words['1_hour']);

$days = array();
for($i = 0; $i < 7; $i++)
{
	$days[$i] = array($i, sprintf($this->lang->words['x_days'],$i));
}
$days[1] = array(1, $this->lang->words['1_day']);

$weeks = array();
for($i = 0; $i < 5; $i++)
{
	$weeks[$i] = array($i, sprintf($this->lang->words['x_weeks'],$i));
}
$weeks[1] = array(1, $this->lang->words['1_week']);

$form['apply'] = ipsRegistry::getClass('output')->formDropdown('applying', $applyTo, $tax['applying']);
$form['minute'] = ipsRegistry::getClass('output')->formDropdown('t_minute', $minute, $tax['t_minute']);
$form['hour'] = ipsRegistry::getClass('output')->formDropdown('t_hour', $hours, $tax['t_hour']);
$form['day'] = ipsRegistry::getClass('output')->formDropdown('t_day', $days, $tax['t_day']);
$form['week'] = ipsRegistry::getClass('output')->formDropdown('t_week', $weeks, $tax['t_week']);
$form['fixed'] = marketFormatter::currencyFormat(ipsRegistry::getClass('output')->formSimpleInput('tax_fix', $tax['tax_fix'], 10));
$form['percent'] = ipsRegistry::getClass('output')->formSimpleInput('tax_percent', $tax['tax_percent'], 10);
$form['percent_min'] = marketFormatter::currencyFormat(ipsRegistry::getClass('output')->formSimpleInput('tax_pmin', $tax['tax_pmin'], 10));
$form['percent_sub'] = marketFormatter::currencyFormat(ipsRegistry::getClass('output')->formSimpleInput('tax_psub', $tax['tax_psub'], 10));
$form['minimum'] = marketFormatter::currencyFormat(ipsRegistry::getClass('output')->formSimpleInput('tax_fix', $tax['range_min'], 10));
$form['maximum'] = marketFormatter::currencyFormat(ipsRegistry::getClass('output')->formSimpleInput('tax_fix', $tax['range_max'], 10));

$IPBHTML .= <<<EOF
<div class='section_title'>
	<h2>{$title}</h2>
</div>

<div id='taxFormPage'>
	<form method='post' action='{$this->settings['base_url']}module=manage&amp;section=taxes&amp;do={$nextDo}' id='taxForm'>
		<input type='hidden' name='_admin_auth_key' value='{$this->registry->adminFunctions->getSecurityKey()}' />
		<input type='hidden' name='tax' value='{$tax['t_id']}' />
		<div class='acp-box'>
			<h3>{$title}</h3>
			<ul class='acp-form alternate_rows'>
				<li>
					<label>{$this->lang->words['tax_apply_to']}</label>
					{$form['apply']}
				</li>
				<li>
					<label>
						{$this->lang->words['tax_how_often']}
						<span class="desctext" style='white-space: nowrap'>{$this->lang->words['tax_how_often_desc']}</span>
					</label>
					<div style='float: left'>
						{$form['week']}
						<br />
						{$form['day']}
						<br />
						{$form['hour']}
						<br />
						{$form['minute']}
					</div>
				</li>
				<li>
					<label>
						{$this->lang->words['tax_range']}
						<span class="desctext" style='white-space: nowrap'>{$this->lang->words['tax_range_desc']}</span>
					</label>
					<div style='float: left'>
						{$this->lang->words['tax_minimum']}: {$form['minimum']}
						<br />
						{$this->lang->words['tax_maximum']}: {$form['maximum']}
					</div>
				</li>
				<li>
					<label>
						{$this->lang->words['tax_fixed']}
						<span class="desctext" style='white-space: nowrap'>{$this->lang->words['tax_fixed_desc']}</span>
					</label>
					{$form['fixed']}
				</li>
				<li>
					<label>
						{$this->lang->words['tax_percent']}
						<span class="desctext" style='white-space: nowrap'>{$this->lang->words['tax_percent_desc']}</span>
					</label>
					{$form['percent']}%
				</li>
				<li>
					<label>
						{$this->lang->words['tax_percent_min']}
						<span class="desctext" style='white-space: nowrap'>{$this->lang->words['tax_percent_min_desc']}</span>
					</label>
					{$form['percent_sub']}
				</li>
				<li>
					<label>
						{$this->lang->words['tax_percent_sub']}
						<span class="desctext" style='white-space: nowrap'>{$this->lang->words['tax_percent_sub_desc']}</span>
					</label>
					{$form['percent_min']}
				</li>
			</ul>
			<div class='acp-actionbar'>
				<div class='centeraction'>
					<input type='submit' value='{$submitValue}' class='button primary'>
				</div>
			</div>
		</div>
	</form>
</div>
EOF;

return $IPBHTML;
}

/**
 * Manage member inventory
 *
 * @access	public
 * @return	string	HTML
 */
public function manageInventory( array $inventoryItems ) {

$IPBHTML .= <<<EOF
<div class='section_title'>
	<h2>{$this->lang->words['manage_member_inventory']}</h2>
</div>

<div id='manageInventory'>
	<form method='post' action='{$this->settings['base_url']}module=manage&amp;section=inventory&amp;do=save&amp;member_id={$this->request['member_id']}' id='manageInventoryForm'>
		<input type='hidden' name='_admin_auth_key' value='{$this->registry->adminFunctions->getSecurityKey()}' />
		<div class='acp-box'>
			<h3>{$this->lang->words['edit_member_inventory']}</h3>
			<table width='100%' cellpadding='0' cellspacing='0' border='0' class='alternate_rows'>
				<tr>
					<th style='width:1px;min-width:1%;white-space:nowrap'>{$this->lang->words['icon']}</th>
					<th style='white-space:nowrap'>{$this->lang->words['name_description']}</th>
					<th style='width:1px;min-width:1%;white-space:nowrap'>{$this->lang->words['time_bought']}/{$this->lang->words['category']}</th>
					<th style='width:1px;min-width:1%;white-space:nowrap'>{$this->lang->words['price']}/{$this->lang->words['resell']}</th>
					<th style='width:1px;min-width:1%;white-space:nowrap'>{$this->lang->words['delete']}</th>
				</tr>

EOF;
foreach($inventoryItems as $invItem)
{
	$bought = $this->registry->getClass('class_localization')->formatTime($invItem['time_bought'],'long');
	$description = IPSText::getTextClass('bbcode')->preDisplayParse(marketRegistry::getItem($this->caches['market_items'][$invItem['item']])->parseInventoryDescription($invItem));
	$price = marketFormatter::currencyFormat(ipsRegistry::getClass('output')->formSimpleInput('price['.$invItem['i_id'].']', $invItem['price_bought'], 10));
	$resell = marketFormatter::currencyFormat(ipsRegistry::getClass('output')->formSimpleInput('resell['.$invItem['i_id'].']', $invItem['resell_price'], 10));
	$delete = ipsRegistry::getClass('output')->formCheckbox('delete['.$invItem['i_id'].']');
	$IPBHTML .= <<<EOF
				<tr>
					<td style='white-space:nowrap'><img src='{$this->settings['market_images_url']}/icons/{$this->caches['market_items'][$invItem['item']]['icon']}' alt='{$this->lang->words['icon']}'></td>
					<td style='white-space:nowrap'>
						<strong>{$this->caches['market_items'][$invItem['item']]['item_name']}</strong>
						<br />
						{$description}
					</td>
					<td style='white-space:nowrap'>
						{$this->lang->words['time_bought']}: {$bought}
						<br />
						{$this->lang->words['category']}: {$this->caches['market_category'][$this->caches['market_items'][$invItem['item']]['category']]['cat_name']}
					</td>
					<td style='white-space:nowrap'>
						{$this->lang->words['price']}: {$price}
						<br />
						{$this->lang->words['resell']}: {$resell}
					</td>
					<td>
						{$delete}
					</td>
				</tr>

EOF;
}
if(count($inventoryItems) == 0)
{
	$IPBHTML .= <<<EOF
				<tr><td colspan='4' style='text-align:center'>{$this->lang->words['no_inventory_item']}</td></tr>

EOF;
}
$IPBHTML .= <<<EOF
			</table>
			<div class='acp-actionbar'>
				<div class='centeraction'>
					<input type='submit' value='{$this->lang->words['save_inventory']}' class='button primary'>
				</div>
			</div>
		</div>
	</form>
</div>
<br />
<div id='addInventory'>
	<form method='post' action='{$this->settings['base_url']}module=manage&amp;section=inventory&amp;do=add&amp;member_id={$this->request['member_id']}' id='addInventoryForm'>
		<input type='hidden' name='_admin_auth_key' value='{$this->registry->adminFunctions->getSecurityKey()}' />
		<div class='acp-box'>
			<h3>{$this->lang->words['add_member_inventory']}</h3>
			<table width='100%' cellpadding='0' cellspacing='0' border='0' class='alternate_rows'>
				<tr>
					<th style='width:1px;min-width:1%;white-space:nowrap'>{$this->lang->words['icon']}</th>
					<th style='white-space:nowrap'>{$this->lang->words['name_description']}</th>
					<th style='width:1px;min-width:1%;white-space:nowrap'>{$this->lang->words['category']}/{$this->lang->words['lasts']}</th>
					<th style='width:1px;min-width:1%;white-space:nowrap'>{$this->lang->words['price']}/{$this->lang->words['resell']}</th>
					<th style='width:1px;min-width:1%;white-space:nowrap'>{$this->lang->words['quanity']}</th>
				</tr>

EOF;
foreach($this->caches['market_items'] as $item)
{
	$description = IPSText::getTextClass('bbcode')->preDisplayParse(marketRegistry::getItem($item)->parseStoreDescription());
	$lasts = $item['expire'] <= 0 ? $this->lang->words['forever'] : marketFormatter::relativeTimeFull($item['expire']);
	$price = marketFormatter::currencyFormat(ipsRegistry::getClass('output')->formSimpleInput('price['.$item['item_id'].']', $item['price'], 10));
	$resell = marketFormatter::currencyFormat(ipsRegistry::getClass('output')->formSimpleInput('resell['.$item['item_id'].']', $item['resell'], 10));
	$quanity = ipsRegistry::getClass('output')->formSimpleInput('quanity['.$item['item_id'].']', 0);
	$IPBHTML .= <<<EOF
				<tr>
					<td style='white-space:nowrap'><img src='{$this->settings['market_images_url']}/icons/{$item['icon']}' alt='{$this->lang->words['icon']}'></td>
					<td style='white-space:nowrap'>
						<strong>{$item['item_name']}</strong>
						<br />
						{$description}
					</td>
					<td style='white-space:nowrap'>
						{$this->lang->words['category']}: {$this->caches['market_category'][$item['category']]['cat_name']}
						<br />
						{$this->lang->words['lasts']}: {$lasts}
					</td>
					<td style='white-space:nowrap'>
						{$this->lang->words['price']}: {$price}
						<br />
						{$this->lang->words['resell']}: {$resell}
					</td>
					<td>
						{$quanity}
					</td>
				</tr>

EOF;
}
if(count($inventoryItems) == 0)
{
	$IPBHTML .= <<<EOF
				<tr><td colspan='4' style='text-align:center'>{$this->lang->words['no_inventory_item']}</td></tr>

EOF;
}
$IPBHTML .= <<<EOF
			</table>
			<div class='acp-actionbar'>
				<div class='centeraction'>
					<input type='submit' value='{$this->lang->words['add_to_inventory']}' class='button primary'>
				</div>
			</div>
		</div>
	</form>
</div>

EOF;

return $IPBHTML;
}

}